Skip to content

Add PreTransactionEvent#6370

Merged
JRoy merged 5 commits intoEssentialsX:2.xfrom
Golfing7:2.x
Apr 5, 2026
Merged

Add PreTransactionEvent#6370
JRoy merged 5 commits intoEssentialsX:2.xfrom
Golfing7:2.x

Conversation

@Golfing7
Copy link
Copy Markdown
Contributor

@Golfing7 Golfing7 commented Dec 2, 2025

Information

I added a PreTransactionEvent for cancelling transactions between users.

Details

Proposed feature:
Adding a PreTransactionEvent.

Environments tested:

OS: Linux Mint

Java version: 23

  • Most recent Paper version (1.XX.Y, git-Paper-BUILD)
  • CraftBukkit/Spigot/Paper 1.12.2
  • CraftBukkit 1.8.8

Demonstration:

    @EventHandler
    public void onPay(PreTransactionEvent event) {
        // Prevent money from being sent outside their own faction.
        IUser userSource = event.getRequester().getUser();
        if (userSource == null)
            return;

        FPlayer fplayerSource = FPlayers.getInstance().getByPlayer(userSource.getBase());
        if (fplayerSource == null || fplayerSource.isAdminBypassing())
            return;

        Faction faction = fplayerSource.getFaction();
        if (faction == null || !isFactionVoluntaryExcluded(faction.getId()))
            return;

        // Who are they sending it to?
        FPlayer target = FPlayers.getInstance().getById(event.getTarget().getUUID().toString());
        Faction factionTarget = target.getFaction();
        if (faction != factionTarget) {
            event.setCancelled(true);
            msg(userSource.getBase(), cantPayOutsideExcludedFactionMessage);
        }
    }

This code prevents transactions between two users when two factions can't interact.

Copy link
Copy Markdown
Member

@JRoy JRoy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if instead PreTransactionEvent extended TransactionEvent and also allowed you to update the amount?

@Golfing7
Copy link
Copy Markdown
Contributor Author

Sorry for the delay, I've made the requested change.

Copy link
Copy Markdown
Contributor

@benediktjohannes benediktjohannes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion

@JRoy
Copy link
Copy Markdown
Member

JRoy commented Apr 5, 2026

thanks :)

@JRoy JRoy added this pull request to the merge queue Apr 5, 2026
Merged via the queue into EssentialsX:2.x with commit 08b7fe3 Apr 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants